package com.siwen.service.impl;

import com.siwen.common.ErrorCode;
import com.siwen.exception.UserException;
import com.siwen.mapper.UserMapper;
import com.siwen.pojo.system.SysUserInformationTbl;
import com.siwen.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
  public class UserServiceImpl implements UserService {
    @Resource
   private UserMapper userMapper;
    /**
     * 查询所有系统后台员工
     * @return
     */
    @Override
    public List<SysUserInformationTbl> getsysUserInfo() {
        return userMapper.getsysUserInfo();
    }
    @Override
    public SysUserInformationTbl login(String admincode, String password) throws UserException{
        if("".equals(admincode)||"".equals(password)){
            throw new UserException(ErrorCode.NULL_VALUE);
        }
        SysUserInformationTbl sysUserInformationTbl= userMapper.login(admincode,password);
        if(sysUserInformationTbl==null){

            throw new UserException(ErrorCode.ACCESS_DENIED);
        }
        return  sysUserInformationTbl;
    }

    @Override
    public int insertUser(SysUserInformationTbl sif) {
        return userMapper.insertUser(sif);
    }


}
